import 'package:appflutterhomeschool/api/api_service.dart';
import 'package:appflutterhomeschool/api/dio_utils.dart';
import 'package:appflutterhomeschool/model/parent_get_homeworks_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../my_app_view_model.dart';

class JobListStatusViewModel extends ChangeNotifier {
  BuildContext me;
  String id;

  JobListStatusViewModel(this.me, this.id);

  bool identity;
  MyAppViewModel myAppViewModel;


  String getImageUrl(String studentId) {
    Dio2Utils.getInstance().post(ApiService.getStudentImg,
        {"student_id": studentId}, (successCallBack) {
          return successCallBack['data']['img'];
        }, (errorCallBack) {
        });

//    return Constant.nullImage;
  }

//列表
  List<ParentGetHomeworksModel> parentGetHomeworkList;

  initView() {
    myAppViewModel = Provider.of(
      me,
    );

    identity = myAppViewModel.identity;
    Dio2Utils.getInstance().get("${ApiService.studentHomeworkList}${id}/", {},
        (successCallBack) {
      List listData = successCallBack["data"];
      parentGetHomeworkList = [];
      if (listData == null) {
        return;
      }
      listData.forEach((element) {
        parentGetHomeworkList.add(ParentGetHomeworksModel.fromJson(element));
      });
      notifyListeners();
    }, (errorCallBack) {});
  }
}
